package com.example.shop.mapper;

import com.example.shop.model.ShopCart;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface ShopCartMapper extends Mapper<ShopCart> {
//    @Select("select s.id, s.uId, s.commodityId, c.`name`, s.created, c.price, s.num, s.sumPrice, s.remark " +
//            "from shopCart s " +
//            "left join commodity c " +
//            "on s.commodityId = c.id " +
//            "where s.uId = #{uId}")
    List<ShopCart> getShopCarts(int uId);

//    @Insert("insert into shopCart value(null, #{uId}, #{commodityId}, #{created}, #{price}, #{num}, #{sumPrice}, #{remark})")
    int insertShopCart(ShopCart shopCart);

    int updateShopCart(ShopCart shopCart);

    //查询单个
//    @Select("select s.*, c.name from shopCart s inner join commodity c on s.commodityId = c.id where commodityId = #{commodityId} and uId = #{uId}")
    ShopCart getShopCart(int commodityId, int uId);

    int getDataCount();

    List<ShopCart> getShopCartPage(@Param("startNum") int startNum, @Param("pageSize") int pageSize, @Param("search") String search);
}
